{{define "Title"}}{{.article.Title}}{{end}}
{{define "ContentWidth"}}10{{end}}
{{define "Breadcrumb"}}
{{$article := .utils.AssertArticle .article}}
<ul class="breadcrumb">
  <li><a href="/"><i class="glyphicon glyphicon-home"></i> 首页</a></li>
  <li><a href="/articles">文章</a></li>
  <li>{{($article.Category .db).Name}}</li>
</ul>
{{end}}
{{define "Content"}}
{{$article := .utils.AssertArticle .article}}
{{$creater := $article.Creater .db}}
<article class="content">
  <h1>{{.article.Title}}</h1>
  {{if .username}}
  {{if $article.CanEdit .username .db}}
  <a href="/a/{{$article.Id_.Hex}}/edit" class="btn btn-info btn-xs pull-right" title="编辑"><i class="glyphicon glyphicon-edit"></i></a>
  <a href="/a/{{$article.Id_.Hex}}/delete" class="btn btn-danger btn-xs pull-right" title="删除" onclick="return confirm('确认删除吗？');"><i class="glyphicon glyphicon-remove"></i></a>
  {{end}}
  {{end}}
  <div>感谢 <a href="/member/{{$creater.Username}}">{{$creater.Username}}</a> 在 <time datetime="{{$article.CreatedAt}}">{{formattime $article.CreatedAt}}</time> 投递 {{.article.Hits}} 次点击</div>
  {{.shareCode}}
  <div class="body">
    <h2><small>文章来源: <a href="{{.article.OriginalUrl}}" target="_blank">{{.article.OriginalSource}}</a></small></h2>
  </div>
</article>
<div id="replies" class="content  editormd-preview-container">
  <span>{{$article.CommentCount}} 评论</span>
  <hr>
  <dl class="replies">
	{{range $index, $comment := $article.Comments .db}}
	<dd id="{{.Id_.Hex}}">
	  <span class="label label-default pull-right">#{{add $index 1}}</span>
	  {{if $.username}}
	  {{if $comment.CanDeleteOrEdit $.username $.db}}
	  <a href="/comment/{{.Id_.Hex}}/delete" class="remove label pull-right" title="删除"><i class="icon-white icon-remove"></i></a>
	  {{end}}
	  {{end}}
	  {{$creater := $comment.Creater $.db}}
	  <a href="/member/{{$creater.Username}}" class="pull-left" style="margin-right: 10px;">
        <img class="img-rounded" src="{{$creater.AvatarImgSrc 48}}" alt="{{$creater.Username}}">
	  </a>
	  <div class="info">
		<a href="/member/{{$creater.Username}}"><strong>{{$creater.Username}}</strong></a> •
		{{formattime .CreatedAt}}
	  </div>
      <div class="space"></div>
      <div class="reply-content">{{.Html}}</div>
      <div class="clear"></div>
	</dd>
	{{end}}
  </dl>
</div>
{{if .username}}
<div id="reply">
  <form action="/comment/{{$article.Id_.Hex}}" method="post" id="reply-form" role="form">
    <fieldset>
      <div class="form-group">
        <label>新回复</label>
        <div id="editormd">
          <textarea style="display: none;"></textarea>
        </div>
      </div>
      <input type="submit" class="btn btn-primary" value="回复" id="submit">
    </fieldset>
  </form>
</div>
<script>
  var editor;
  
  $(function () {
    $('#submit').attr('disabled', true);

    editor = createEditorMd("editormd", "#submit");
  });
</script>
{{else}}
<div class="content" style="padding: 2em;">
  需要 <a href="/signin" class="btn btn-primary">登录</a> 后方可回复, 如果你还没有账号你可以 <a href="/signup" class="btn btn-danger">注册</a> 一个帐号。
</div>
{{end}}
{{end}}

{{define "LeftSide"}}{{end}}
{{define "RightSide"}}
<div class="col-md-2">
  <a href="/article/new" class="btn btn-info btn-lg btn-block" style="margin-bottom: 20px;">转载文章</a>
</div>
{{end}}
